package com.optionexplorer.data;

import java.util.Date;
import org.json.simple.JSONObject;

import com.optionexplorer.util.DateUtils;

public class StockOption {
	
	public static String CALL_OPTION = "Call";
	public static String PUT_OPTION = "Put";

	protected float stockPrice;
	protected String symbol; 
	protected Date   expirationDate;
	protected float  strikePrice;
	protected float  premium;
	protected long   volume;
	protected long   openInt;

	protected int remDays;
	
	/* additional attributes for call options*/
	protected float roe;
	protected float percentRoe;
	protected float downBuf;
	protected float percentDownBuf;
	protected float annualYield;
	protected float annualDownBuf;
	
	/* additional attributes for put options */
	protected float discount;
	protected float percentDiscount;
	protected float putRoe;
	protected float percentPutRoe;
	
	public StockOption() {
		
	}
	
	public StockOption(float stockPr,
					   String symb, 
					   Date expDate, 
					   float strikePr, 
					   float premium, 
					   long vol, 
					   long openInt) {
		this.stockPrice = stockPr;
		this.symbol = symb;
		this.expirationDate = expDate;
		this.strikePrice = strikePr;
		this.premium = premium;
		this.volume = vol;
		this.openInt = openInt;	
	}
	
	
	public String toString() {		
		StringBuilder sb = new StringBuilder();
		sb.append(this.stockPrice + "\t");
		//sb.append(this.getType() + "\t");
		sb.append(this.symbol + "\t");
		sb.append(this.strikePrice + "\t");
		sb.append(this.premium + "\t");
		//sb.append(this.expirationDate + "\t");
		sb.append(printAdditionalMetrics());
		sb.append("\n");	
		return sb.toString();
	}

	public JSONObject toJSONObject() {
		JSONObject obj = new JSONObject();
		obj.put("sym", this.symbol);
		obj.put("strike", this.strikePrice);
		obj.put("premium", this.premium);		
		obj.put("exp", DateUtils.formatSimple(this.expirationDate));
		obj.put("ty", getType());
		
		return obj;
	}
	
	public Date getExpirationDate() {
		return expirationDate;
	}

	public void setExpirationDate(Date expirationDate) {
		this.expirationDate = expirationDate;
	}

	public float getStrikePrice() {
		return strikePrice;
	}

	public float getStockPrice() {
		return stockPrice;
	}
	
	public void setStrikePrice(float strikePrice) {
		this.strikePrice = strikePrice;
	}

	public float getPremium() {
		return premium;
	}

	public void setPremium(float premium) {
		this.premium = premium;
	}

	public long getVolume() {
		return volume;
	}

	public void setVolume(long volume) {
		this.volume = volume;
	}

	public long getOpenInt() {
		return openInt;
	}

	public void setOpenInt(long openInt) {
		this.openInt = openInt;
	}

	public String getType() {
		return "";
	}
	
	public String printAdditionalMetrics() {
		return "";
	}

	protected float getROE() {
		return this.roe;
	}
	
	protected float getPercentROE() {
		return this.percentRoe;
	}
	
	protected float getPercentDownBuf() {
		return this.percentDownBuf;
	}
	
	public String getSymbol() {
		return this.symbol;
	}
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {		
				
	}

}
